package memorphic.utils
{
	public class XMLNamespaceUtil
	{
		
		/**
		 * Recursively applies a default namespace to an XML element and all of its children
		 */
		public static function applyDefaultNamespace(target:XML, ns:Namespace):void
		{
			target.setNamespace(ns);
			for each(var child:XML in target.children()){
				// !prefix -> it is already in a default ns
				// !uri -> it isn't in any namespace
				if(!child.namespace() || !child.namespace().prefix || !child.namespace().uri){
					applyDefaultNamespace(child, ns);
				}
			}
		}
	}
}